<?php
session_start();
require_once(dirname(__FILE__)."/../libs/dbclass/dbconnect.php");
require_once(dirname(__FILE__)."/../libs/string/libstr.php");
require_once(dirname(__FILE__)."/../libs/public/public_func.php");
$mc= new libstr();
if($mc->Ismp($_POST["zuotibtn"])!=""){
	$tiku_id=$_POST["tiku_id"];
	 $teacherno=$_POST["teacherno"];
	  $daan=$_POST["daan"];
	  $shijuan_id=$_POST["shijuan_id"];
	  $studentno=$_POST["studentno"];
       $iscorrect="";
       
   $fp_count=$db->dvstr("select id,istijiao from fenpei_shijuan where shijuan_id=' ".$shijuan_id."' and studentno='".$studentno."'"); //判断是否已经提交
   if($fp_count["istijiao"]=='1')  {
   	echo "have answer";
   	exit();
   }
for($i=0;$i<count($tiku_id);$i++){
	//exit($tiku_id[$i]);
		$st=$db->dvstr("select daan from tiku_content where tiku_id=' ".$tiku_id[$i]."'");
		$dtArray=array();
		$dtArray["tiku_id"]=$tiku_id[$i];
		$dtArray["teacherno"]=$teacherno;
		$dtArray["studentno"]=$studentno;
		//$dtArray["jiazhangno"]=$v;
		$dtArray["shijuan_id"]=$shijuan_id;
		$dtArray["daan"]=$daan[$i];
		$dtArray["zhengquedaan"]=$st["daan"];
		
		if(strtolower($daan[$i])==strtolower($st["daan"])){
			$dtArray["correct"]=1;	
			$iscorrect.="1,";
		}else{
			$dtArray["correct"]=0;
			$iscorrect.="0,";
		}
		$dtArray["riqi"]=time();
		$answer=$db->add_data("answer_content",$dtArray);//插入答题表
		$db->cmd("update fenpei_shijuan set istijiao=1,submittime=".time()." where studentno='".$studentno."' and shijuan_id=".$shijuan_id);
		
}
   $iscorrect=substr($iscorrect,0,strlen($iscorrect)-1);
	echo "answer is ok|answer=".$iscorrect;//答题成功，返回答案错对提示
}
?>